﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HeresyManager.Comunication;

public partial class ChooseOneControl : System.Web.UI.UserControl
{
    private ChooseOne chooseOne;



    public ChooseOne ChooseOne
    {
        get { return chooseOne; }
        set { chooseOne = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (chooseOne != null)
        {
            this.Label1.Text = chooseOne.Question;
            this.DropDownList1.DataSource = chooseOne.Posebilitys;
            DropDownList1.DataBind();
            RandomButton.Visible = chooseOne.IsRandomSupported;
            if (RandomButton.Visible)
            {
                RandomButton.Text = chooseOne.Dice.ToString();
                RandomButton_Click(null, null);
            }
            chooseOne.SelectedIndex = DropDownList1.SelectedIndex;
        }
        else
        RandomButton.Visible = false;
    }
                                             


    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        chooseOne.SelectedIndex = DropDownList1.SelectedIndex;
    }
    protected void RandomButton_Click(object sender, EventArgs e)
    {
        chooseOne.Random();
        DropDownList1.SelectedIndex=chooseOne.SelectedIndex;
    }
}